package com.apes.scm.masterdata.finance.model;

import com.apes.framework.jpa.DefaultPersistListener;
import com.apes.framework.jpa.Model;
import com.apes.framework.jpa.comment.Comment;
import com.apes.framework.jpa.generator.ApesGenerator;
import com.apes.framework.jpa.generator.Implementation;
import com.apes.scm.masterdata.frame.model.Dept;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.SelectBeforeUpdate;

import javax.persistence.*;

/**
 * 绑定POS机
 *
 * @author wuq
 * @create 2018-08-14 10:20
 */

@Getter
@Setter
@SelectBeforeUpdate
@DynamicInsert
@DynamicUpdate
@Entity
@EntityListeners(DefaultPersistListener.class)
@Table(name = PosBind.CONST_TABLE_NAME)
public class PosBind  extends Model {
    public static final String CONST_TABLE_NAME = "mas_Pos_Bind";

    @Id
    @Column(name = "id", length = 6)
    @ApesGenerator(code = CONST_TABLE_NAME, name = "绑定POS机", padding= 4, implementation = Implementation.NO_GAP)
    @Comment("编码")
    private String id;  //编码

    @Column(name = "pos_number", length = 8)
    @Comment("POS机编码")
    private String posNumber;  //POS机编码

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "dept_id", referencedColumnName = "id", nullable = false)
    @Comment("对应部门")
    private Dept dept;    //对应部门

    /* todo 未加的字段
     *银行账号
     *地点字段
     */

    @Column(name = "valid", nullable = false, columnDefinition = "number(1,0) default 1")
    @Comment("有效标记")
    private boolean valid; //有效
}
